package com.gxa.service.impl;

import com.gxa.common.R;
import com.gxa.common.Status;
import com.gxa.mapper.CustomerReportMapper;
import com.gxa.service.CustomerReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CustomerReportServiceImpl implements CustomerReportService {
    @Autowired
    CustomerReportMapper customerReportMapper;

    /**
     * 根据status统计客服数量
     * @return
     */
    @Override
    public R getCustomerReportStatus() {
        R r =new R();
        List customerReportList = customerReportMapper.selectCustomerReportList();
        if(customerReportList.size()>0){
            r.fromStatus(Status.SUCCESS);
            r.setData(customerReportList);
        }else{
            r.fromStatus(Status.SYSTEM_ERROR);
        }
        return r;
    }

    /**
     * 根据客服type统计数量
     * @return
     */
    @Override
    public R getCustomerReportType() {
        R r = new R();
        List getCustomerReportType = customerReportMapper.selectCustomerReportType();
        if(getCustomerReportType != null){
            r.setCode(200);
            r.setMsg("success");
            r.setData(getCustomerReportType);
        }else {
           r.fromStatus(Status.SYSTEM_ERROR);
        }
        return r;
    }

    /**
     * 根据客服date统计数量（年月）
     * @return
     */
    @Override
    public R getCustomerDate() {
        R r = new R();
        List getCustomerDate = customerReportMapper.selectCustomerReportDate();
        if (getCustomerDate !=null){
            r.setData(getCustomerDate);
            r.fromStatus(Status.SUCCESS);
        }else {
            r.fromStatus(Status.SYSTEM_ERROR);
        }
        return r;
    }

    /**
     * 根据客服date统计数量（年月日）
     * @return
     */
    @Override
    public R getYearReport() {
        R r = new R();
        List getYearReport = customerReportMapper.selectYearReport();
        if (getYearReport.size()>0){
            r.setCode(200);
            r.setMsg("success");
            r.setData(getYearReport);
        }
        return  r;
    }
}
